var Yiyonghaocai = new Vue({
    el : "#Yiyonghaocailist",
    data :{
        xiangmuId : $("#xiangmuId").val(),
        xiangmuleixing: "",
        xiangmu : {},
        yiyonghaocai :{},
        yiyonghaocailist : [],
        show : false,					// 显示列表是否有数据

        pageIndex : 1,
        pageSize :9999,
        pageCount : 0,
        recordCount : 0,
        inputPageIndexValue : "",

    },

    created : function() {
        var _this = this;
        xiangmuId=_this.xiangmuId;
        _this.bindXiangmu();

    },
    methods : {
        toback : function() {
            window.history.go(-1);
        },
        bindXiangmu:function (){
            var _this = this;
            layer.open({type:3});

            $.post('/xiangmu/find_one', {
                xianmguid : _this.xiangmuId,
                rdm : Math.random()
            },function(ppData) {
                layer.closeAll("loading");
                if(ppData != null){
                    if(ppData.result == "1"){
                        var data = ppData.resultContent;
                        _this.xiangmu = data;
                        _this.xiangmuleixing = data.xiangmuleixing;
                        _this.bindYiyonghaocaiList();
                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },
        toDelete:function (){
            var _this = this;

            layer.confirm("确定删除该项目的材料吗？",{
                btn : ['是','否']
            },function(){
                layer.open({type:3});

                $.post("/yiyonghaocai2/delete", {
                    xiangmuid : _this.xiangmuId,
                    random : Math.random()
                }, function(ppData) {
                    if (ppData != null) {
                        layer.closeAll("loading");

                        if(ppData.result != "1"){
                            layer.alert(ppData.message);
                        }else{
                            layer.open({
                                time:1000,
                                btn:[],
                                content:"删除成功!",
                            });
                            _this.bindXiangmu();
                        }
                    }
                },"json");
            })
        },

        bindYiyonghaocaiList:function (){
            var _this = this;
            layer.open({type:3});
            $.post("/jieguo/findlist",{
                xiangmuid : _this.xiangmuId,
                xiangmuleixing : _this.xiangmuleixing,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;
                        var mmHtml = "<div class='table-head'><table class=\"table table-hover table-bordered\" style=\"overflow:hidden; margin-bottom:10px;table-layout:fixed;\" v-if=\"show\" cellspacing=\"0\" cellpadding=\"0\">\n" +
                            "   <thead >\n" +
                            "    <tr style=\"font-weight: bold;\">\n" +
                            "       <td rowspan='2' style=\"text-align:center;vertical-align:middle;width:60px;\" >序号</td>\n" +
                            "       <td rowspan='2' style=\"text-align:center;vertical-align:middle;width:60px;\" >引进类型</td>\n" +
                            "       <td rowspan='2' style=\"text-align:center;vertical-align:middle;width:60px;\" >总序号</td>\n" +
                            "       <td colspan='6' style=\"text-align:center;vertical-align:middle;\" >设备信息</td>\n" +
                            "       <td colspan='9' style=\"text-align:center;vertical-align:middle;\" >配套耗材（试剂）信息</td>\n" +
                            "       <td rowspan='2' style=\"text-align:center;vertical-align:middle;width:60px;\" >国产/进口</td>\n" +
                            "    </tr>\n" +
                            "    <tr style=\"font-weight: bold;\">\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >设备名称</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >设备型号</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >设备来源</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >启用日期</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >设备序列号</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >设备生产厂家</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >平台编码</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >产品名称</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >规格</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >型号</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >注册证号</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >生产厂家</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >单位</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >单价</td>\n" +
                            "       <td style=\"text-align:center;vertical-align:middle;width:60px;\" >医保编码</td>\n" +
                            "    </tr>\n" +
                            "   </thead></table></div><div class='table-body'><table style=\"table-layout: fixed;\"><tbody>";
                        if(data.Biaojuelist.length > 0){
                            _this.show = true;
                            _this.pinpailist=data.Biaojuelist;
                            _this.resultlist=data.Resultlist;

                            for (var i = 0; i < data.Biaojuelist.length; i++) {
                                var pinpaiOne = data.Biaojuelist[i];

                                var pinguilist = pinpaiOne.pinguilist;
                                var mmPinpaiHebingshu = pinpaiOne.pinpaihebinghang;
                                var mmPinzhong = pinpaiOne.zongxuhao;


                                var zongxuhao = pinpaiOne.zongxuhao;
                                var shebeimingcheng = pinpaiOne.shebeimingcheng;
                                var shebeixinghao = pinpaiOne.shebeixinghao;
                                var shebeilaiyuan = pinpaiOne.shebeilaiyuan;
                                var qiyongriqi = pinpaiOne.qiyongriqi;
                                var shebeixuliehao = pinpaiOne.shebeixuliehao;
                                var shebeishengchanchangjia = pinpaiOne.shebeishengchanchangjia;

                                for (var j = 0; j < pinguilist.length; j++) {
                                    var s=0;

                                    var pinguiOne = pinguilist[j];
                                    var id=pinguiOne.id;
                                    var result=pinguiOne.result;
                                    var ordernum = pinguiOne.ordernum;
                                    var yinjinleixing = pinguiOne.yinjinleixing;
                                    var pingtaibianma = pinguiOne.pingtaibianma;
                                    var chanpinmingcheng = pinguiOne.chanpinmingcheng;
                                    var guige = pinguiOne.guige;
                                    var xinghao = pinguiOne.xinghao;
                                    var zhucezhenghao = pinguiOne.zhucezhenghao;
                                    var shengchanchangjia = pinguiOne.shengchanchangjia;
                                    var danwei = pinguiOne.danwei;
                                    var danjia = pinguiOne.danjia;
                                    var yibaobianma = pinguiOne.yibaobianma;
                                    var guochanjinkou = pinguiOne.guochanjinkou;
                                    var beizhu = pinguiOne.beizhu;
                                    var shenqingkeshi = pinguiOne.shenqingkeshi;
                                    var mmPinpai = pinguiOne.ordernum;
                                    var isvote = pinguiOne.isvote;

                                    var mmHuanhangfu = "";
                                    var mmyijihe="";

                                    mmHtml += mmHuanhangfu + "<td style='text-align:center;vertical-align:middle;width: 60px;'>" + ordernum + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;'>" + yinjinleixing + "</td>";

                                    if(j==0 &&s==0){
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;width: 60px;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + zongxuhao + "</td>";
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + shebeimingcheng + "</td>";
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + shebeixinghao + "</td>";
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + shebeilaiyuan + "</td>";
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + qiyongriqi + "</td>";
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + shebeixuliehao + "</td>";
                                        mmyijihe+= "<td style='text-align:center;vertical-align:middle;height: 100%'  rowspan='" + mmPinpaiHebingshu + "'>" + shebeishengchanchangjia + "</td>";
                                        s= 1;
                                    }
                                    mmHtml +=mmyijihe;
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + pingtaibianma + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + chanpinmingcheng + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + guige + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + xinghao + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + zhucezhenghao + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + shengchanchangjia + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + danwei + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + danjia + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;'>" + yibaobianma + "</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;'>" + guochanjinkou + "</td>";

                                    mmHtml += "</tr>";

                                }
                            }

                        }else {
                            _this.show = false;
                        }
                        mmHtml += "</table>";
                        $("#List").html(mmHtml);
                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },



    },
});
